/*
 * @Author: your name
 * @Date: 2020-06-10 10:59:40
 * @LastEditTime: 2020-06-11 15:42:38
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \account-client\src\container\manage\index.js
 */
import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';

export default function (props) {
    const { match } = props;
    const { Routes } = props;
    return (
        <Switch>
            {
                Routes.map(o =>
                    <Route
                        key={o.path}
                        exact={o.exact}
                        path={`${match.url}/${o.path}`}
                        render={
                            (prop) => {
                                return <o.component {...prop} Routes={o.children || o.sibling || []} />
                            }
                        }
                    />
                )
            }
            <Redirect from={match.url} to={`${match.url}/${Routes[Routes.length - 1].path}`} />
        </Switch>
    )
}
